home *** CD-ROM | disk | FTP | other *** search
- class classes.enemy.ShipBoss
- {
- var x;
- var y;
- var color;
- var moveScript;
- var d;
- var clip;
- var lifeOrig;
- var trans;
- var colorTrans;
- var dir;
- var f2;
- var axis;
- var xDest;
- var yDest;
- var ep;
- var laserCount;
- var laserMax;
- var oldDir;
- var colorR;
- var xMov = 0;
- var yMov = 0;
- var xMovT = 0;
- var yMovT = 0;
- var speedOrig = 12;
- var speed = 12;
- var xDestMet = false;
- var yDestMet = false;
- var c = 0;
- var life = 100;
- var nc = 0;
- var xA = 0;
- var yA = 0;
- var nudging = false;
- var power = 25;
- var foreground = true;
- var smoke = true;
- var actionCount = 0;
- var dOrange = 20;
- var dPurple = 21;
- var dGreen = 22;
- var dRed = 23;
- var moveScript1Orange = ["L",820,"U",1000,"break"];
- var moveScript1Purple = ["R",450,"D",1000,"break"];
- var moveScript1Green = ["L",190,"U",1000,"break"];
- var moveScript1Red = ["L",190,"break"];
- var Name = "shipBoss";
- function ShipBoss(px, py, pcolor, pmoveScript)
- {
- this.x = px;
- this.y = py;
- this.color = pcolor;
- this.moveScript = pmoveScript.slice();
- _root.d = _root.d + 1;
- this.d = _root.d + 190000;
- this.clip = _root.attachMovie("shipBoss","shipBoss" + this.color + "Clip",this.d);
- this.clip._x = this.x;
- this.clip._y = this.y;
- this.speed *= _root.dif.speed;
- this.speedOrig = this.speed;
- this.life *= _root.dif.life;
- this.lifeOrig = this.life;
- this.trans = new flash.geom.Transform(this.clip);
- this.colorTrans = new flash.geom.ColorTransform(1,1,1,1,0,0,0,0);
- this.clip.body.colors.gotoAndStop(this.color);
- this.clip.body.flame1.gotoAndPlay("main");
- this.clip.body.flame2.gotoAndPlay("main");
- this.clip.swapDepths(this["d" + this.color]);
- this.foreground = false;
- this.smoke = false;
- this.colorTrans.blueOffset = -255;
- this.colorTrans.redOffset = -255;
- this.colorTrans.greenOffset = -255;
- this.trans.colorTransform = this.colorTrans;
- this.clip._xscale = 66;
- this.clip._yscale = 66;
- this.speed *= 0.66;
- this.parseMoveScript();
- _root.shipBossCount = 3;
- _root.boss = true;
- if(this.color == "Green")
- {
- this.clip.body.windShield.gotoAndStop(2);
- }
- if(this.color == "Red")
- {
- this.clip.body.windShield.gotoAndStop(3);
- this.life = 1000;
- this.speed = 18;
- this.speedOrig = 18;
- this.speed *= _root.dif.speed;
- this.speedOrig = this.speed;
- this.life *= _root.dif.life;
- }
- _root.stats.created = _root.stats.created + 1;
- }
- function nudge(pxA, pyA, pscale)
- {
- this.nc = 0;
- this.nudging = true;
- var _loc2_ = pscale / 600;
- this.xA = pxA * _loc2_;
- this.yA = pyA * _loc2_;
- }
- function bombed(num)
- {
- }
- function parseMoveScript()
- {
- var _loc2_ = this.dir;
- this.dir = this.moveScript[0];
- if(this.dir == "break")
- {
- delete this.moveScript;
- this.f2 = "flying";
- this.dir = _loc2_;
- }
- else
- {
- this[this.axis + "MovT"] = 0;
- this.f2 = "gotoXYDest";
- this.axis = !(this.dir == "L" || this.dir == "R") ? "y" : "x";
- this[this.axis + "MovT"] = !(this.dir == "L" || this.dir == "U") ? this.speed : -1 * this.speed;
- if(this.dir == "L" || this.dir == "U")
- {
- this[this.axis + "Dest"] = this[this.axis] - this.moveScript[1];
- }
- else
- {
- this[this.axis + "Dest"] = this[this.axis] + this.moveScript[1];
- }
- this.moveScript.splice(0,2);
- }
- }
- function gotoXYDest()
- {
- if(Math.abs(this[this.axis + "Dest"] - this[this.axis]) < this.speed + 1)
- {
- if(this.axis == "x")
- {
- this.x = this.xDest;
- }
- else
- {
- this.y = this.yDest;
- }
- this.parseMoveScript();
- }
- }
- function getDirString()
- {
- if(this.xMovT < -1)
- {
- this.dir = "L";
- }
- else if(this.xMovT > 1)
- {
- this.dir = "R";
- }
- else if(this.yMovT > 1)
- {
- this.dir = "D";
- }
- else if(this.yMovT < -1)
- {
- this.dir = "U";
- }
- }
- function leaving()
- {
- this.xMovT * 1.04;
- }
- function blast(flameVar)
- {
- if(flameVar)
- {
- this.clip.body.flame1.gotoAndPlay("end");
- this.clip.body.flame2.gotoAndPlay("end");
- }
- this.xMovT = 0;
- this.yMovT = 0;
- this.smoke = false;
- this.clip.body.gotoAndPlay("fireStart");
- this.clip.body.colors.clip.gotoAndPlay("fireStart");
- this.f2 = "blasting";
- this.c = 0;
- _root.audio.playLevel2("shipBossBlast2",_root.randRange(45,65));
- }
- function blasting()
- {
- this.c = this.c + 1;
- if(this.c == 6)
- {
- this.clip.body.charge.gotoAndPlay("go");
- }
- if(this.c == 30)
- {
- var _loc3_ = this.dir != "L" ? 39 : 9;
- _root["shipBossBlast" + this.color] = new classes.shots.ShipBossBlast(this.x + _loc3_,this.y + 12,this.color,this.dir,this.color);
- _root.addEnemyShot("shipBossBlast" + this.color);
- var _loc4_ = this.dir != "L" ? -50 : 50;
- this.nudge(_loc4_,0,100);
- }
- }
- function closeTurrets()
- {
- this.clip.body.gotoAndPlay("fireEnd");
- this.clip.body.colors.clip.gotoAndPlay("fireEnd");
- }
- function endBlast()
- {
- this.actionCount = this.actionCount + 1;
- if(this.actionCount == 1)
- {
- this.fly(true);
- }
- else if(random(2) > 0)
- {
- this.strafe(false);
- }
- else
- {
- this.fly(true);
- }
- }
- function fly(fly2)
- {
- if(fly2)
- {
- this.f2 = "flying2";
- }
- else
- {
- this.f2 = "flying";
- }
- this.smoke = true;
- this.clip.body.flame1.gotoAndPlay("start");
- this.clip.body.flame2.gotoAndPlay("start");
- this[this.axis + "MovT"] = this.dir != "R" ? -1 * this.speed : this.speed;
- }
- function missleRun()
- {
- this.c = 0;
- this.ep = _root.randRange(2,20);
- this.f2 = "missleRunning";
- }
- function missleRunning()
- {
- this.c = this.c + 1;
- if(this.c == this.ep)
- {
- if(this.dir == "U")
- {
- var _loc3_ = 3;
- var _loc5_ = 24;
- var _loc6_ = 30;
- var _loc4_ = 24;
- }
- else
- {
- _loc3_ = 3;
- _loc5_ = 3;
- _loc6_ = 30;
- _loc4_ = 3;
- }
- _root.enemyShotID = _root.enemyShotID + 1;
- _root["shipBossMissle" + _root.enemyShotID] = new classes.shots.ShipBossMissle(this.x + _loc3_,this.y + _loc5_,this.color,this.dir,this.speed,_root.enemyShotID);
- _root.addEnemyShot("shipBossMissle" + _root.enemyShotID);
- _root.enemyShotID = _root.enemyShotID + 1;
- _root["shipBossMissle" + _root.enemyShotID] = new classes.shots.ShipBossMissle(this.x + _loc6_,this.y + _loc4_,this.color,this.dir,this.speed,_root.enemyShotID);
- _root.addEnemyShot("shipBossMissle" + _root.enemyShotID);
- if(this.speed > 12)
- {
- this.c = 0;
- this.ep = _root.randRange(7,20);
- }
- _root.audio.playLevel3("shipBossMissle2",_root.randRange(10,20));
- }
- }
- function strafe(flameVar)
- {
- if(flameVar)
- {
- this.clip.body.flame1.gotoAndPlay("end");
- this.clip.body.flame2.gotoAndPlay("end");
- }
- this.xMovT = 0;
- this.c = 0;
- this.ep = _root.randRange(30,300);
- this.smoke = false;
- this.yMovT = random(2) <= 0 ? this.speed * -0.215 : this.speed * 0.215;
- this.f2 = "strafing";
- }
- function strafing()
- {
- this.c = this.c + 1;
- if(random(200) > 198)
- {
- this.blast(false);
- }
- else if(random(100) > 97)
- {
- this.fireLaser();
- }
- if(this.y < 120)
- {
- this.yMovT = this.speed * 0.215;
- }
- if(this.y > 430)
- {
- this.yMovT = this.speed * -0.215;
- }
- if(this.c == this.ep)
- {
- this.yMovT = 0;
- this.fly(true);
- }
- }
- function fireLaser()
- {
- this.clip.body.gotoAndPlay("fireStart");
- this.clip.body.colors.clip.gotoAndPlay("fireStart");
- this.f2 = "firingLaser";
- this.laserCount = 0;
- this.laserMax = this.speed != 12 ? _root.randRange(2,5) : _root.randRange(1,3);
- this.c = 0;
- }
- function firingLaser()
- {
- this.c = this.c + 1;
- if(this.c == 15)
- {
- if(this.dir == "L")
- {
- var _loc3_ = -24;
- var _loc9_ = -3;
- var _loc10_ = -24;
- var _loc8_ = 30;
- var _loc7_ = -24;
- var _loc5_ = -12;
- var _loc6_ = -24;
- var _loc4_ = 30;
- }
- else
- {
- _loc3_ = 45;
- _loc9_ = -3;
- _loc10_ = 45;
- _loc8_ = 30;
- _loc7_ = 45;
- _loc5_ = -12;
- _loc6_ = 45;
- _loc4_ = 30;
- }
- _root.enemyShotID = _root.enemyShotID + 1;
- _root["shipBossLaserA" + _root.enemyShotID] = new classes.shots.ShipBossLaserA(this.x + _loc3_,this.y + _loc9_,this.color,this.dir,this.speed,_root.enemyShotID);
- _root.addEnemyShot("shipBossLaserA" + _root.enemyShotID);
- _root.enemyShotID = _root.enemyShotID + 1;
- _root["shipBossLaserA" + _root.enemyShotID] = new classes.shots.ShipBossLaserA(this.x + _loc10_,this.y + _loc8_,this.color,this.dir,this.speed,_root.enemyShotID);
- _root.addEnemyShot("shipBossLaserA" + _root.enemyShotID);
- _root.enemyShotID = _root.enemyShotID + 1;
- _root["shipBossLaserB" + _root.enemyShotID] = new classes.shots.ShipBossLaserB(this.x + _loc7_,this.y + _loc5_,this.color,"U" + this.dir,this.speed,_root.enemyShotID);
- _root.addEnemyShot("shipBossLaserB" + _root.enemyShotID);
- _root.enemyShotID = _root.enemyShotID + 1;
- _root["shipBossLaserB" + _root.enemyShotID] = new classes.shots.ShipBossLaserB(this.x + _loc6_,this.y + _loc4_,this.color,"D" + this.dir,this.speed,_root.enemyShotID);
- _root.addEnemyShot("shipBossLaserB" + _root.enemyShotID);
- _root.audio.playLevel3("shipBossLaser",_root.randRange(25,40));
- this.c = 0;
- this.laserCount = this.laserCount + 1;
- if(this.laserCount == this.laserMax)
- {
- this.yMovT = 0;
- this.closeTurrets();
- this.c = 100;
- }
- }
- if(this.c == 108)
- {
- this.yMovT = 0;
- this.fly(true);
- }
- if(this.y < 120)
- {
- this.yMovT = this.speed * 0.215;
- }
- if(this.y > 430)
- {
- this.yMovT = this.speed * -0.215;
- }
- }
- function flying()
- {
- if(this.foreground)
- {
- if(this.x < 850 && this.x > 100 && this.actionCount == 0)
- {
- this.blast(true);
- }
- else if(this.x < 870 && this.x > 80 && this.y > 80 && this.y < 470 && this.actionCount > 3)
- {
- if(this.axis == "x")
- {
- var _loc2_ = random(3);
- if(_loc2_ == 0)
- {
- this.blast(true);
- }
- else if(_loc2_ == 1)
- {
- this.strafe(true);
- }
- else
- {
- this.f2 = "";
- }
- }
- else
- {
- this.missleRun();
- }
- }
- }
- else if(this.x < 1000 && this.x > 0 && this.actionCount == 2)
- {
- this.actionCount = this.actionCount + 1;
- this.moveScript = this["moveScript1" + this.color];
- this.parseMoveScript();
- }
- else if(random(100) > 96)
- {
- if(this.axis == "y" && this.y > 100 && this.y < 450 && this.actionCount > 3)
- {
- this.yMovT = 0;
- this.axis = "x";
- this.xMovT = random(2) <= 0 ? -1 * this.speed : this.speed;
- this.getDirString();
- }
- }
- else if(random(100) > 98)
- {
- if(this.axis == "x" && this.x < 850 && this.x > 100)
- {
- this.xMovT = 0;
- this.axis = "y";
- this.yMovT = random(2) <= 0 ? -1 * this.speed : this.speed;
- this.getDirString();
- }
- }
- }
- function goBackground()
- {
- this.clip.swapDepths(this["d" + this.color]);
- this.foreground = false;
- this.smoke = false;
- this.colorTrans.blueOffset = -255;
- this.colorTrans.redOffset = -255;
- this.colorTrans.greenOffset = -255;
- this.trans.colorTransform = this.colorTrans;
- this.clip._xscale = 66;
- this.clip._yscale = 66;
- this.speed *= 0.66;
- this.xMovT *= 0.66;
- this.yMovT *= 0.66;
- this.reverseDir();
- this.f2 = "flying";
- this.actionCount = this.actionCount + 1;
- }
- function goForeground()
- {
- this.clip.swapDepths(this.d);
- this.foreground = true;
- this.smoke = true;
- this.colorTrans.blueOffset = 0;
- this.colorTrans.redOffset = 0;
- this.colorTrans.greenOffset = 0;
- this.trans.colorTransform = this.colorTrans;
- this.clip._xscale = 100;
- this.clip._yscale = 100;
- this.speed = this.speedOrig;
- this.xMovT /= 0.66;
- this.yMovT /= 0.66;
- this.reverseDir();
- delete this.moveScript;
- this.f2 = "flying";
- }
- function death()
- {
- _root.audio.playLevel2("shipBossX" + (random(3) + 1),_root.randRange(30,40));
- _root.stats.destroyed = _root.stats.destroyed + 1;
- _root.stats.score += 10000;
- var _loc3_ = this.color;
- if(_loc3_ == "Orange")
- {
- _loc3_ = "Red";
- }
- var _loc4_ = 0;
- var _loc5_ = _root.randRange(5,8);
- while(_loc4_ < _loc5_)
- {
- _root.createExploA([this.x + this.clip._width / 2 + _root.randRange(-50,50),this.y + this.clip._height / 2 + _root.randRange(-50,50),_root.randRange(80,150),_root.randRange(75,100),_loc3_]);
- _loc4_ = _loc4_ + 1;
- }
- _loc4_ = 0;
- _loc5_ = _root.randRange(6,10);
- while(_loc4_ < _loc5_)
- {
- _root.createShrapnel([this.x + this.clip._width / 2,this.y + this.clip._height / 2,"shipBoss" + this.color,_loc3_,true]);
- _loc4_ = _loc4_ + 1;
- }
- if(this.color != "Red")
- {
- _root.createPowerUp([this.x,this.y,"coin10"]);
- _root.createPowerUp([this.x,this.y,"coin10"]);
- _root.createPowerUp([this.x,this.y,"coin10"]);
- }
- else
- {
- _root.createPowerUp([this.x,this.y,"coin25"]);
- _root.createPowerUp([this.x,this.y,"coin25"]);
- _root.createPowerUp([this.x,this.y,"coin25"]);
- }
- if(this.color == "Orange")
- {
- _root.createPowerUp([this.x,this.y,"weaponBoost"]);
- }
- else if(this.color == "Green")
- {
- _root.createPowerUp([this.x,this.y,"speedBoost"]);
- }
- else if(this.color == "Purple")
- {
- _root.createPowerUp([this.x,this.y,"lifeUp"]);
- _root.createPowerUp([this.x,this.y,"lifeUp"]);
- }
- else
- {
- _root.createPowerUp([this.x,this.y,"lifeUp"]);
- _root.createPowerUp([this.x,this.y,"lifeUp"]);
- _root.createPowerUp([this.x,this.y,"shield"]);
- }
- _root.shipBossOrange.speed += 3;
- _root.shipBossGreen.speed += 3;
- _root.shipBossPurple.speed += 3;
- _root.shipBossOrange.speedOrig += 3;
- _root.shipBossGreen.speedOrig += 3;
- _root.shipBossPurple.speedOrig += 3;
- _root.shipBossCount = _root.shipBossCount - 1;
- if(_root.shipBossCount == 0)
- {
- delete _root.shipBossCount;
- _root.boss = false;
- _root.initLevel2();
- }
- if(this.color == "Red")
- {
- _root.removeRandoms([1]);
- _root.boss = false;
- }
- _root.removeChar("shipBoss" + this.color);
- }
- function death2()
- {
- _root.removeChar("shipBoss" + this.color);
- }
- function reverseDir()
- {
- if(this.dir == "L")
- {
- this.dir = "R";
- this.xMovT = this.speed;
- this.yMovT = 0;
- this.x += 150;
- }
- else if(this.dir == "R")
- {
- this.dir = "L";
- this.xMovT = -1 * this.speed;
- this.yMovT = 0;
- this.x -= 150;
- }
- else if(this.dir == "U")
- {
- this.dir = "D";
- this.xMovT = 0;
- this.yMovT = this.speed;
- this.y += 150;
- }
- else if(this.dir == "D")
- {
- this.dir = "U";
- this.xMovT = 0;
- this.yMovT = -1 * this.speed;
- this.y -= 150;
- }
- }
- function main()
- {
- this[this.f2]();
- if(this.oldDir != this.dir)
- {
- this.clip.gotoAndStop(this.dir);
- }
- this.oldDir = this.dir;
- if(this.foreground)
- {
- if(this.nudging)
- {
- this.xA *= 0.7;
- this.yA *= 0.7;
- this.nc = this.nc + 1;
- var _loc8_ = 255 - this.nc * 17;
- this.colorTrans.redOffset = _loc8_;
- this.trans.colorTransform = this.colorTrans;
- if(this.nc == 15)
- {
- this.xA = this.yA = 0;
- this.nudging = false;
- this.colorTrans.blueOffset = this.colorR;
- this.colorTrans.greenOffset = this.colorR;
- this.colorTrans.redOffset = this.colorR;
- this.trans.colorTransform = this.colorTrans;
- }
- }
- var _loc4_ = 0;
- var _loc7_ = _root.broShots.length;
- while(_loc4_ < _loc7_)
- {
- var _loc6_ = _root.broShots[_loc4_] + "Clip";
- if(this.clip.hitTest(_root[_loc6_]))
- {
- if(this.x < 950 && this.x > 0 && this.y > 0 && this.y < 550)
- {
- var _loc3_ = _root.broShots[_loc4_];
- var _loc5_ = this.life;
- this.life -= _root[_loc3_].power;
- this.clip.body.d1.gotoAndStop(Math.ceil((100 - this.life / this.lifeOrig * 100) / 20));
- this.clip.body.d2.gotoAndStop(Math.ceil((100 - this.life / this.lifeOrig * 100) / 20));
- this.clip.body.d3.gotoAndStop(Math.ceil((100 - this.life / this.lifeOrig * 100) / 20));
- if(this.life < 1)
- {
- this.f2 = "death";
- }
- else
- {
- this.nudge(_root[_loc3_].xMov,_root[_loc3_].yMov,10);
- _root.audio.playLevel4("shipBossHit" + (random(3) + 1),_root.randRange(15,25));
- }
- _root[_root.char].fc = _root[_root.char].fireFreq - _root.rapidVar;
- _root[_loc3_].exploX = this.x + this.clip._width / 2;
- _root[_loc3_].exploY = this.y + this.clip._height / 2;
- _root[_loc3_].hit(_loc5_);
- }
- }
- _loc4_ = _loc4_ + 1;
- }
- if(this.clip.hitTest(_root[_root.char + "Clip"]))
- {
- _root[_root.char].hit(this.xMov,this.yMov,100,this.power);
- this.nudge(_root.randRange(-6,6),_root.randRange(-6,6),100);
- }
- }
- if(this.smoke)
- {
- if(random(10) > 6)
- {
- if(this.dir == "L")
- {
- var _loc10_ = this.x + 51;
- var _loc9_ = this.y + _root.randRange(12,27);
- }
- else if(this.dir == "R")
- {
- _loc10_ = this.x + -6;
- _loc9_ = this.y + _root.randRange(12,27);
- }
- else if(this.dir == "U")
- {
- _loc10_ = this.x + _root.randRange(12,27);
- _loc9_ = this.y + 48;
- }
- else
- {
- _loc10_ = this.x + _root.randRange(12,27);
- _loc9_ = this.y + -6;
- }
- _root.shrapID = _root.shrapID + 1;
- _root["shipSmoke" + _root.shrapID] = new classes.fx.ShipSmoke(_loc10_,_loc9_,_root.shrapID);
- _root.addFX("shipSmoke" + _root.shrapID);
- }
- }
- if(this.x > 1200 || this.x < -200 || this.y < -200 || this.y > 800)
- {
- if(this.foreground)
- {
- this.goBackground();
- }
- else
- {
- this.goForeground();
- }
- }
- if(this.xMovT < this.xMov)
- {
- this.xMov -= 2;
- }
- else if(this.xMovT > this.xMov)
- {
- this.xMov += 2;
- }
- else
- {
- this.xMov = this.xMovT;
- }
- if(this.yMovT < this.yMov)
- {
- this.yMov -= 2;
- }
- else if(this.yMovT > this.yMov)
- {
- this.yMov += 2;
- }
- else
- {
- this.yMov = this.yMovT;
- }
- this.x += this.xMov + this.xA;
- this.y += this.yMov + this.yA;
- this.clip._x = this.x;
- this.clip._y = this.y;
- }
- }
-